package org.jeecg.modules.wlhy.hyopenapi.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.api.dto.openapi.RoutePathDTO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.wlhy.hyopenapi.service.IHyOpenAPIService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 封装中交OPENAPI给feign调用
 */
@RestController
@RequestMapping("/feignopenapi")
@Slf4j
public class ZjOpenAPIController {

    @Autowired
    private IHyOpenAPIService hyOpenAPIService;

    @PostMapping(value = "/routepath")
    public Result<?> routePath(@RequestBody RoutePathDTO routePathDTO) {
        log.info("获取中交轨迹消息，{}", JSONUtil.toJsonStr(routePathDTO));
        return hyOpenAPIService.getRoutePath(routePathDTO);
    }

    @PostMapping(value = "/transTimeManage")
    public Result<?> transTimeManage(@RequestBody List<RoutePathDTO> routePathDTOList) {
        log.info("获取中交运输节点消息，{}", JSONUtil.toJsonStr(routePathDTOList));
        if (CollUtil.isEmpty(routePathDTOList)) {
            return Result.error("运输节点请求参数不能为空");
        }

        return hyOpenAPIService.getTransTimeManage(routePathDTOList);
    }

}
